"use strict";
cc._RF.push(module, '03e485+rClHUqITHxBmBM72', 'CoinMenu');
// scripts/CoinMenu.js

"use strict";

var e = require;
var t = module;
var n = exports;
Object.defineProperty(n, "__esModule", {
  value: !0
});

var o = e("DataMgr"),
    i = e("VideoHint"),
    a = cc._decorator,
    r = a.ccclass,
    s = a.property,
    c = function (e) {
  __extends(t, e);

  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.coinLabel = null;
    t.addBtnNode = null;
    t._updateMoneyTick_coin = null;
    return t;
  }

  t.prototype.onLoad = function () {
    o.GlobalEvent.on("CoinChange", this.UpdataCoinNum, this);
  };

  t.prototype.start = function () {
    this.UpdataCoinNum(0, o["default"].Instance.coinNum, !1);
    this.addBtnNode && (this.addBtnNode.active = SDK.Mgr.Inst.hasAds);
  };

  t.prototype.onDestroy = function () {
    o.GlobalEvent.off("CoinChange", this.UpdataCoinNum, this);
  };

  t.prototype.adBtnClick = function () {
    var e = "AddCoin_Ad";
    SDK.Mgr.Inst.event(e + "Click");

    var t = function t(n) {
      if (n == SDK.Define.AdsCode.finish) {
        SDK.Mgr.Inst.event(e + "Success");
        o["default"].Instance.coinNum += 100;
        o["default"].Instance.videoAdTimes++;
      } else if (n == SDK.Define.AdsCode.cancel) {
        SDK.Mgr.Inst.event(e + "Cancel");
        i["default"].Instance.openPanel(t);
      } else {
        SDK.ToastMgr.Inst.showToast("暂无广告，请稍后再试");
        SDK.Mgr.Inst.event(e + "NoAd");
      }
    };

    SDK.Mgr.Inst.showVideo(t);
  };

  t.prototype.UpdataCoinNum = function (e, t, n) {
    void 0 === n && (n = !0);

    if (n) {
      if (this._updateMoneyTick_coin) {
        this.unschedule(this._updateMoneyTick_coin);
        this._updateMoneyTick_coin = null;
      }

      for (var o = [], i = t - e, a = 0; a <= 4; a++) {
        o.push(e + .25 * i * a);
      }

      var r = 0,
          s = this;

      this._updateMoneyTick_coin = function () {
        s.coinLabel.string = o[r++].toString();
      };

      this.schedule(this._updateMoneyTick_coin, .1, 4, .2);
    } else this.coinLabel.string = t.toString();
  };

  __decorate([s(cc.Label)], t.prototype, "coinLabel", void 0);

  __decorate([s(cc.Node)], t.prototype, "addBtnNode", void 0);

  return __decorate([r], t);
}(cc.Component);

n["default"] = c;

cc._RF.pop();